home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / misc / pdflib / bind / python / hello.py next >
Text File  |  1999-12-06  |  740b  |  36 lines

  1. #!/usr/bin/python
  2. # hello.py
  3. # Copyright (C) 1997-99 Thomas Merz. All rights reserved.
  4. #
  5. # PDFlib client: hello example in Python
  6. #
  7.  
  8. from sys import *
  9. from pdflib import *
  10.  
  11. p = PDF_new()
  12.  
  13. if PDF_open_file(p, "hello_py.pdf") == -1:
  14.     print 'Couldn\'t open PDF file!', "hello_py.pdf"
  15.     exit(2);
  16.  
  17. PDF_set_info(p, "Author", "Thomas Merz")
  18. PDF_set_info(p, "Creator", "hello.py")
  19. PDF_set_info(p, "Title", "Hello world (Python)")
  20.  
  21. PDF_begin_page(p, 595, 842)
  22. font = PDF_findfont(p, "Helvetica-Bold", "default", 0)
  23. if font == -1:
  24.     print 'Couldn\'t set font!'
  25.     exit(3);
  26.  
  27. PDF_setfont(p, font, 18.0)
  28.  
  29. PDF_set_text_pos(p, 50, 700)
  30. PDF_show(p, "Hello world!")
  31. PDF_continue_text(p, "(says Python)")
  32. PDF_end_page(p)
  33. PDF_close(p)
  34.  
  35. PDF_delete(p);
  36.